# coding=utf-8
def _round(num, ndigits):
    '''
        1.2345678
        ndigits:
            2 --> 1.23
            3 --> 1.235
    '''
    n = 10 ** (ndigits + 1) * num / 10
    if n % 4:
        return (n /10 + 1) * 1.0 / (10 ** ndigits)
    
if __name__ == "__main__":
    print _round(1.2345678, 2)
    print _round(1.2345678, 3)
    print _round(1.2345678, 4)
    print _round(1.2345678, 5)